<template>
  <div class="sBar animated fadeRight">
      
    <div class="bar1 " ></div>
    <div class="bar2 ">
        <ul class="sidebar-list">
            <li class="sidebar_cons_li"><img class="icon" src="https://assets-cdn.lanqb.com/imgv3/sidebar/money-ccx2x.png" width="24" height="24"><em>课程咨询</em></li>
            <li class="sidebar_cons_li" ><img class="icon" src="https://assets-cdn.lanqb.com/imgv3/sidebar/stc-zygh2x.png?imageView2/1/w/24/h/24" width="24" height="24"><em>职业规划</em></li>
            <li class="sidebar_cons_li"><img class="icon" src="https://assets-cdn.lanqb.com/imgv3/sidebar/stc-tzjd2x.png?imageView2/1/w/24/h/24" width="24" height="24"><em>挑战接单</em></li>
            <li class="sidebar_cons_li"><img class="icon" src="https://assets-cdn.lanqb.com/imgv3/sidebar/stc-zyts2x.png?imageView2/1/w/24/h/24" width="24" height="24"><em>专业提升</em></li>
            <li class="retop " @click="retop"><img class="icon" src="https://assets-cdn.lanqb.com/imgv3/sidebar/retopx2x.png" width="24" height="24"></li>
        </ul>
    </div>
  </div>
</template>
<script>
export default {
methods:{
    retop(){
     let top = document.documentElement.scrollTop || document.body.scrollTop;
      // 实现滚动效果 
      const timeTop = setInterval(() => {
        document.body.scrollTop = document.documentElement.scrollTop = top -= 50;
        if (top <= 0) {
          clearInterval(timeTop);
        }
      }, 10);
    }
},
mounted(){
  //不加可能无法监听滚动事件
 window.addEventListener('scroll', this.scrollToTop)
}
}
</script>
<style lang="scss" scoped>
.sBar {
  width: 80px;
  position: fixed;
  z-index: 300;
  right: 40px;
  bottom: 140px;
}
.bar1 {
  width: 80px;
  height: 70px;
  margin-bottom: 10px;
  background: url(https://assets-cdn.lanqb.com/popupv3/2021/aug_s0826.png?v=5)
    no-repeat 50%;
  background-size: 80px 80px;
  cursor: pointer;
}
.bar2{
    position: relative;
    text-align: center;
}
.sidebar-list {
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgb(0 0 0 / 9%);
    list-style: none;
    display: block;
    li {
    padding-top: 8px;
    padding-bottom: 8px;
    border-bottom: 0.5px solid #EEEEEE ;
    cursor: pointer;
       transition: all 0.6s;
    &:hover{
        background-color: rgb(241,249,255);
    }
          }
    .icon{
    display: block;
    width: auto;
    height: 24px;
    margin: 0 auto;
    }
    em{
    margin-top: 2px;
    font-size: 12px;
    line-height: 18px;
    color: #666;
    white-space: nowrap;
    font-style: normal;
    }
}

.fadeRight {
  animation-name: fadeRight;
}

@keyframes fadeRight {
  from {
    opacity: 0;
    transform: translate3d(100%,0,0);
  }
  to {
    opacity: 1;
    transform: translateZ(0);
  }
}
.animated {
 animation: fadeRight 1s ease;
}
</style>